//
//  ToastManager.m
//  KingSelected
//
//  Created by 杨鹏 on 2023/10/27.
//

#import "ToastManager.h"


@implementation ToastManager

+ (void)showToast:(NSString *)text {
    if (text.length <= 0) {
        return;
    }
    dispatch_async(dispatch_get_main_queue(), ^{
        UIView *v = [UIApplication sharedApplication].delegate.window;
        UIView *old = [v viewWithTag:123456];
        if (old) {
            [old removeFromSuperview];
        }
        MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:v animated:YES];
        hud.tag = 123456;
        hud.removeFromSuperViewOnHide = YES;
        hud.mode = MBProgressHUDModeText;
        hud.bezelView.style = MBProgressHUDBackgroundStyleSolidColor;
        hud.bezelView.color = kRGB_ALPHA(0x000000, 0.7);
        hud.bezelView.layer.cornerRadius = 8;
        hud.label.text = text;
        hud.label.textColor = [UIColor whiteColor];
        hud.label.textAlignment = NSTextAlignmentCenter;
        hud.label.font = kFontMediium(13);
        hud.label.numberOfLines = 0;
        [hud hideAnimated:YES afterDelay:3];
    });
}
@end
